<template>
	<view class="home">
		<view class="view-search">
			<input class="name-input" placeholder="请输入姓名" v-model="name" />
			<view class="btn-search" @click="queryDetail">查询</view>
		</view>
		<view class="parent-content">
			<view v-for="(item,index) in contentList" :key="index">
				<view class="content-title">{{item.title}}</view>
				<view v-for="(child,index) in item.expList" :key="index">
					<view class="content-exp">{{child}}</view>
				</view>
				<view class="line" />
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name: "",
				contentList: []
			}
		},
		onLoad(e) {
			this.name = e.name;
		},
		methods: {
			queryDetail() {
				uni.request({
					url: "https://route.showapi.com/1617-5?showapi_appid=1179359&showapi_sign=07c0de6901f642e0a2ccf41d486ecd76",
					data: {
						surname: "曾",
						name: this.name,
					},
					complete: (res) => {
						console.log(JSON.stringify(res));
						this.contentList = res.data.showapi_res_body.contentList
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	.home {
		display: flex;
		flex-direction: column;

		.view-search {
			display: flex;
			align-items: center;
			margin-left: 25rpx;
			margin-right: 25rpx;

			.name-input {
				flex-grow: 1;
				height: 50px;
				border-radius: 25px;
				padding-left: 15rpx;
				border: 1px solid grey;
			}

			.btn-search {
				display: flex;
				justify-content: center;
				align-items: center;
				color: white;
				margin-left: 25rpx;
				background-color: green;
				border-radius: 15px;
				height: 30px;
				width: 70px;
			}
		}

		.parent-content {
			margin-left: 20rpx;
			margin-top: 20rpx;
			width: 710rpx;

			.content-title {
				font-weight: bold;
				color: black
			}

			.line {
				height: 5px;
				margin-top: 10px;
				width: 750rpx;
				background-color: #EFEFEF;
			}

		}
	}
</style>
